package cn.wx.scholar.neo4j.repository;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.Neo4jRepository;
/*import org.springframework.data.neo4j.repository.GraphRepository;*/
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import cn.wx.scholar.neo4j.entity.Neo4jSocial;

@Repository
public interface SocialRepository extends Neo4jRepository<Neo4jSocial,Long> {
	
	/**
	 * 查询某个专家相关的所有社交媒体数据，带分页
	 * @param expertId
	 * @param pageable
	 * @return
	 */
	@Query(value="match(e:expert)-[r:about]-(s:social) where ID(e)={expertId} return s order by s.time desc ",
			countQuery="match(e:expert)-[r:about]-(s:social) where ID(e)={expertId} return count(ID(s))")
	Page<Neo4jSocial> findAllSocialByExpertId(@Param("expertId") Long expertId,Pageable pageable);
	
	@Query("match(s:social) where ID(s)={id} return s")
	Neo4jSocial findSocialDetailById(@Param("id") Long id);	//查询某个社交媒体数据的详情
	
}
